package com.drool.mediaplayer;

import com.drool.mediaplayer.Database.MediaFilesDB;
import com.drool.mediaplayer.Database.MediaFilesDBHelper;

import android.app.Activity;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.SimpleCursorAdapter;

public class PlaylistSelectActivity extends Activity {

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    
	    getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
                WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
        
	    setContentView(R.layout.layplaylistselect);
	    
	    ListView plList = (ListView)findViewById(R.id.playlistSelList);
		final MediaFilesDBHelper myDBHelper = new MediaFilesDBHelper(this);	
		final SQLiteDatabase db = myDBHelper.getReadableDatabase();
		final Cursor c = db.query(MediaFilesDB.Playlist.PLAYLIST_TABLE_NAME 
				,new String[] {MediaFilesDB.Playlist._ID,
				MediaFilesDB.Playlist.PLAYLIST_NAME},
				null, 
				null, null, null, MediaFilesDB.Playlist.PLAYLIST_CREATED_ON + " Desc");
		startManagingCursor(c);
		
		ListAdapter adapter = new SimpleCursorAdapter(this, R.layout.laysimple, c, 
				new String[]{
				MediaFilesDB.Playlist.PLAYLIST_NAME
		}, new int[]{
				R.id.simpletxt
		});
		
		plList.setAdapter(adapter);
		
			    
	    // TODO Auto-generated method stub
	}

}
